/**
 * Copyright (C)  2011  chen wei hua.
 * Permission is granted to copy, distribute and/or modify this document
 * under the terms of the GNU Free Documentation License, Version 2.0
 * or any later version published by the Free Software Foundation;
 * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 * A copy of the license is included in the section entitled "GNU Free Documentation License".
 */
package com.javaeye.common.web;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class BaseReportAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1998966732318406119L;
	
	private List<ReportData> reportDatas;
	
	private int queryDateType;
	
	public String getColumnsJOSN() {
		StringBuffer sb = new StringBuffer();
		sb.append("[");
		int index = 0;
		int count = reportDatas.size();
		for (ReportData data : reportDatas) {
			sb.append("'");
			sb.append(data.getColumn());
			sb.append("'");
			if (index < count - 1) {
				sb.append(",");
			}
			index++;
		}
		sb.append("]");
		return sb.toString();
	}
	
	public String getDatasJOSN() {
		StringBuffer sb = new StringBuffer();
		sb.append("[");
		int index = 0;
		int count = reportDatas.size();
		for (ReportData data : reportDatas) {
			sb.append(data.getData());
			if (index < count - 1) {
				sb.append(",");
			}
			index++;
		}
		sb.append("]");
		return sb.toString();
	}
	
	//@JSON(name="pieDataJSON")
	public String getPieDataJSON() {
		StringBuffer sb = new StringBuffer();
		sb.append("[");
		int index = 0;
		int count = reportDatas.size();
		for (ReportData data : reportDatas) {
			sb.append("['");
			sb.append(data.getColumn());
			sb.append("',");
			sb.append(data.getPrecent());
			sb.append("]");
			if (index < count - 1) {
				sb.append(",");
			}
			index++;
		}
		sb.append("]");
		return sb.toString();
	}

	public List<ReportData> getReportDatas() {
		return reportDatas;
	}

	public void setReportDatas(List<ReportData> reportDatas) {
		this.reportDatas = reportDatas;
	}

	public int getQueryDateType() {
		return queryDateType;
	}

	public void setQueryDateType(int queryDateType) {
		this.queryDateType = queryDateType;
	}
	
}
